home *** CD-ROM | disk | FTP | other *** search
- situation planetary_squad
- vars
- me : squad;
- my_race : integer;
- my_location : integer;
- target : integer;
- focus : squad;
- loc : integer;
- success : boolean;
-
- begin
- // Find the nearest enemy squad and move toward it
- me := This_squad();
- my_race := Squad_race(me);
- my_location := Squad_hex(me);
- target := -1;
- focus := First_squad(-1);
- while (focus <> nil) do
- begin
- if (Squad_race(focus) <> my_race) then
- begin
- loc := Squad_hex(focus);
- if (target = -1) then
- begin
- target := loc;
- end;
- else
- begin
- if (Planet_distance(my_location, loc) <
- Planet_distance(my_location, target)) then
- target := loc;
- end;
- end;
- focus := Next_squad(focus, -1);
- end;
- if (target = -1) then
- success := Move_squad(my_location);
- else
- begin
- success := Move_squad(target);
- if (not success) then
- success := Move_squad(my_location);
- end;
- end;
-